//
//  StatusRetweetedCell.swift
//  MicroBlog
//
//  Created by  NorthCity on 15/11/11.
//  Copyright © 2015年  NorthCity. All rights reserved.
//

import UIKit

class StatusRetweetedCell: StatusCell {
//    微博视图模型
    override var viewModel:StatusViewModel?{
        didSet{
           pictureView.snp_updateConstraints { (make) -> Void in
            let offset  = viewModel?.thumbnailUrls?.count == 0 ? 0:StatusCellMargin
            make.top.equalTo(retweetedLabel.snp_bottom).offset(offset)
            }
            
            retweetedLabel.text = viewModel?.retweetedText
        }
    }
    
    
//MARK: - 懒加载控件
    private lazy var backButton:UIButton={
        let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.85, alpha: 1.0)
        return btn
    }()
    
    private lazy var retweetedLabel :UILabel = UILabel(
        title: "哈哈哈",
        fontSize: 14,
        color: UIColor.darkGrayColor(),
        screenInsert: StatusCellMargin
        )
    
    
   
}
//MARK:设置 布局
extension StatusRetweetedCell{
    override func setUpUI() {
        super.setUpUI()
//        1 添加控件
        contentView.insertSubview(backButton, belowSubview:pictureView)
        contentView.insertSubview(retweetedLabel, aboveSubview: backButton)
//        2 自动布局
        backButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentLabel.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.bottom.equalTo(bottomView.snp_top)
        }
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(backButton.snp_top).offset(StatusCellMargin)
            make.left.equalTo(backButton.snp_left).offset(StatusCellMargin)
        }
        
        pictureView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedLabel.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(retweetedLabel.snp_left)
            make.width.equalTo(300)
            make.height.equalTo(90)
        }

        
    }
}
